package com.xbongbong.config;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.saas.analytical.SaasValidateAnalyticalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 吴峰
 * @date 2021/07/20 9:44
 */
@Configuration
public class AnalyticalService {

    @Autowired
    @Lazy
    private Map<String, SaasValidateAnalyticalService> analyticalServiceMap;

    @Bean("analyticalServiceMap")
    public Map<Integer, SaasValidateAnalyticalService> initFieldAnalyseMapMap() {
        Map<Integer, SaasValidateAnalyticalService> resultMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        this.analyticalServiceMap.forEach((key, item)->{
            item.type().forEach(type->{
                resultMap.put(type, item);
            });
        });
        return resultMap;
    }
}
